package com.bosssoft.trainee.nontax.service.impl;

import com.bosssoft.trainee.nontax.dao.RolePermissionDao;
import com.bosssoft.trainee.nontax.entity.po.RolePermission;
import com.bosssoft.trainee.nontax.service.RolePermissionService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

/**
 * @Description: (RolePermission)表服务实现类
 * @author makejava
 * @since 2022-06-12 10:16:42
 */
@Service("rolePermissionService")
public class RolePermissionServiceImpl implements RolePermissionService {
    @Resource
    private RolePermissionDao rolePermissionDao;

    /**
     * @Description: 分页查询
     * @param rolePermission 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<RolePermission> queryByPage(RolePermission rolePermission, PageRequest pageRequest) {
        long total = this.rolePermissionDao.count(rolePermission);
        return new PageImpl<>(this.rolePermissionDao.queryAllByLimit(rolePermission, pageRequest), pageRequest, total);
    }

    /**
     * @Description: 新增数据
     * @param rolePermission 实例对象
     * @return 实例对象
     */
    @Override
    public RolePermission insert(RolePermission rolePermission) {
        this.rolePermissionDao.insert(rolePermission);
        return rolePermission;
    }

    /**
     * @Description: 修改数据
     * @param rolePermission 实例对象
     * @return 实例对象
     */
    @Override
    public int update(RolePermission rolePermission) {
        return this.rolePermissionDao.update(rolePermission);
    }
}
